﻿@inherits EditOperationDialogBase<FunctionDto, Guid,SystemAssetResource>

<Form Loading="@_dialogLoading.Value"
      Model="@_editModel"
      LabelCol="new ColLayoutParam { Span = 8 }"
      WrapperCol="new ColLayoutParam { Span = 16 }"
      OnFinish="OnFormFinish"
      Context="model">
    <FormItem>
        <Input @bind-Value="@model.Id" Disabled="base.operationIsOnlyReadData" />
    </FormItem>
    <FormItem>
        <AutoComplete @bind-Value="@model.ModuleName" Options="@modules"></AutoComplete>
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.Group" Disabled="base.operationIsOnlyReadData" />
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.Tags" Disabled="base.operationIsOnlyReadData" />
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.Key" Disabled="base.operationIsOnlyReadData" />
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.Path" Disabled="base.operationIsOnlyReadData" />
    </FormItem>
    <FormItem Label="@Localizer[nameof(SharedLocalResource.Method)]">
        <Select DataSource="EnumHelper.EnumToDictionary<ApiHttpMethod>()"
                TItem="KeyValuePair<ApiHttpMethod,string>"
                TItemValue="ApiHttpMethod"
                ItemValue="x=>x.Key"
                ItemLabel="x=>Localizer[x.Value]"
                @bind-Value="model.Method"
                Style="width:120px;"
                Disabled="base.operationIsOnlyReadData">
        </Select>
    </FormItem>
    <FormItem>
        <Input @bind-Value="@model.Summary" Disabled="base.operationIsOnlyReadData" />
    </FormItem>
    <FormItem>
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Description" Disabled="base.operationIsOnlyReadData"></TextArea>
    </FormItem>
    <FormItem>
        <Switch @bind-Value="@model.EnableAudit" Disabled="base.operationIsOnlyReadData"></Switch>
    </FormItem>
    <FormItem>
        <Switch @bind-Value="@model.IsLocked" Disabled="base.operationIsOnlyReadData"></Switch>
    </FormItem>

    @if (this.Options.Type.Equals(OperationDialogInputType.Edit) || this.Options.Type.Equals(OperationDialogInputType.Select))
    {
        <FormItem Label="@Localizer[nameof(SharedLocalResource.CreatedTime)]">
            <span>@model.CreatedTime.ToString(ClientConstant.DateTimeFormat)</span>
        </FormItem>
        <FormItem Label="@Localizer[nameof(SharedLocalResource.UpdatedTime)]">
            <span>@model.UpdatedTime?.ToString(ClientConstant.DateTimeFormat)</span>
        </FormItem>
    }
    <FormItem WrapperColOffset="8" WrapperColSpan="16">
        <Space>
            @if (!OperationDialogInputType.Select.Equals(this.Options.Type))
            {
                <SpaceItem>
                    <Button Type="@ButtonType.Primary" HtmlType="submit">
                        @Localizer[nameof(SharedLocalResource.Save)]
                    </Button>
                </SpaceItem>
            }
            <SpaceItem>
                <Button OnClick="_=>OnFormCancel()">
                    @Localizer[nameof(SharedLocalResource.Cancel)]
                </Button>
            </SpaceItem>
        </Space>
    </FormItem>
</Form>